/**
 * 
 */
package sc12project.milestone1.payment;

import javax.xml.bind.JAXBException;

import business.BankFacade;

/**
 * @author Danielondon
 *
 */
public class PaymentWSImpl implements PaymentWS {
	
	/* (non-Javadoc)
	 * @see SC12Project.Milestone1.Payment.PaymentWS#queryAccount(java.lang.String)
	 */
	@Override
	public int queryAccount(String accountID) {
		// Call the Query Account of the BankFacade
		BankFacade facade = null;
		int balance = 0;
		try {
			facade = new BankFacade();
		} catch (JAXBException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		try {
			balance = facade.queryAccount(accountID);
		} catch (JAXBException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return balance;
	}

	/* (non-Javadoc)
	 * @see SC12Project.Milestone1.Payment.PaymentWS#transfer(java.lang.String, java.lang.String, int)
	 */
	@Override
	public boolean transfer(String accountID1, String accountID2, int amount)
			throws TransactionException {
		// Call the Transfer of the BankFacade
		BankFacade facade = null;
		try {
			facade = new BankFacade();
		} catch (JAXBException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			return facade.transfer(accountID1, accountID2, amount);
		} catch (JAXBException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return false;
	}

	@Override
	public boolean createAccount(String accountID, int amount) {
		
		// Call the Transfer of the BankFacade
		BankFacade facade = null;
		try {
			facade = new BankFacade();
		} catch (JAXBException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			return facade.createAccount(accountID, amount);
		} catch (JAXBException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return false;
	}

}
